var Request = require('../request')
const $request = new Request()
const config = require('../../config')

class dataArrangeModule {
    /**
     * 功能描述
     * @param {*} params
     * @param {*} res
     * @param {*} req
     */

    //引入数据源组件
    joinResource(params, res, req){
        params.data = params.data.data;
        let apiUrl = config.serverUrl_BI + "/bi/etl/resource/join";
        $request.handleRequest({
          method: 'post',
          params: params,
          actionUrl: apiUrl,
        }, res);
      }

  //移除数据源组件
  removeResource(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/component/remove";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //引入输出组件
  joinOut(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/out/join";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //更新引入输出组件
  resetJoinOut(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/out/update";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //节点数据预览
  nodePreview(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/component/data/preview";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //处理组件
  nodeHandle(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/component/handle";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //节点关联
  nodeJoin(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/join/join";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //更新  节点关联
  resetNodeJoin(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/join/update";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //组件关联
  componentConnect(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/biComponentConnection/link";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //查看单个组件详情（状态检测）
  componentInfo(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/biComponent/getComponent";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }


  //取消组件关联  /biComponentConnection/cancel
  componentDisconnect(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/biComponentConnection/cancel";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }


  //run job
  rjob(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/biEtlModel/run";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //触发执行 model
  triggerModel(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/biEtlModel/trigger";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //聚合
  groupJoin(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/group/join";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //更新 聚合
  resetGroupJoin(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/group/update";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //字段拆分
  arrangeSplitJoin(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/split/join";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

    //更新 字段拆分
    resetRangeSplitJoin(params, res, req){
      params.data = params.data.data;
      let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/split/update";
      $request.handleRequest({
        method: 'post',
        params: params,
        actionUrl: apiUrl,
      }, res);
    }
  

  //字段移除
  arrangeRemoveJoin(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/remove/join";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //更新 字段移除
  resetArrangeRemoveJoin(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/remove/update";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //获取模型文件夹树
  getModelTree(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/biEtlModel/getModelTree";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //获取单个节点的详情
  getModel(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/biEtlModel/getModel";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //更新节点图最新内容
  updateContent(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/biEtlModel/updateContent";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  // //排空
  // removeNone(params, res, req){
  //   params.data = params.data.data;
  //   let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/nonnull/join";
  //   $request.handleRequest({
  //     method: 'post',
  //     params: params,
  //     actionUrl: apiUrl,
  //   }, res);
  // }

  //  //更新排空
  //  resetRemoveNone(params, res, req){
  //   params.data = params.data.data;
  //   let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/nonnull/update";
  //   $request.handleRequest({
  //     method: 'post',
  //     params: params,
  //     actionUrl: apiUrl,
  //   }, res);
  // }

  //排空
  removeNone(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/nullValue/join";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

   //更新排空
   resetRemoveNone(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/nullValue/update";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //排空数据预览
  removeNonePreview(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/component/nullData/preview";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }



  //组合字段
  combinField(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/combine/join";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //更新组合字段
  resetCombinField(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/combine/update";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }



  //字段重命名
  renameField(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/modify/join";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }


   //更新字段重命名
   resetRenameField(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/modify/update";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }


  //获取分组字段值
  groupFieldData(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/component/fieldData/preview";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

//分组字段值
groupField(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/group/join";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}


//更新分组字段值
resetGroupField(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/group/update";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}


//字段大小写转换
caseConversion(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/case/join";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

//更新字段大小写转换
resetCaseConversion(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/case/update";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

//去字段空格
clearEmpty(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/blank/join";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}


//更新去字段空格
resetClearEmpty(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/blank/update";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

//数据源组件同步状态实时查看
realTimeView(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/bi/etl/resource/realTimeView";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

//字段内容替换
replaceField(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/replace/join";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}


//更新字段内容替换
resetReplaceField(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/replace/update";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

//查询任务列表
taskList(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/biEtlSyncPlan/list";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

//修改数据源组件
resourceUpdate(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/bi/etl/resource/update";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

//获取数据集文件夹
dataSetGetFiles(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/biDataSet/getFiles";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

// 创建数据集文件夹
dataSetCreateFolder(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/biDataSet/file/create";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}
// 创建数据集文件夹
dataSetRenameFolder(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/biDataSet/reNameFile";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

// 基于文件夹户获取数据集列表
getDataSetPage(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/biDataSet/getDataSetPage";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

// 创建数据集
dataSetCreate(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/biDataSet/create";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

// 数据集的表重命名
dataSetReName(params, res, req){
  params.data = params.data.data;
  let apiUrl = config.serverUrl_BI + "/biDataSet/reName";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}
 //计算字段
  calculateField(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/calculate/join";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //更新 计算字段
  resetCalculateField(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/arrange/calculate/update";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

// 删除数据集
dataSetDelete(params, res, req){
  params.data = params.data.id;
  let apiUrl = config.serverUrl_BI + "/biDataSet/del";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}

// 数据集结果预览（分页）
getDataSetInfoPage(params, res, req){
  let apiUrl = config.serverUrl_BI + "/biDataSet/getDataSetInfoPage";
  $request.handleRequest({
    method: 'post',
    params: params,
    actionUrl: apiUrl,
  }, res);
}
  //计算字段  表達式驗證
  checkFormula(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/component/formula/check";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  //获取操作符列表
  getOperators(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/bi/etl/component/formula/getOperators";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }


  //组件重命名
  renameComponent(params, res, req){
    params.data = params.data.data;
    let apiUrl = config.serverUrl_BI + "/biComponent/rename";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  
  // 预览表字段值
  fieldDataPreview(params, res, req){
    let apiUrl = config.serverUrl_BI + "/bi/etl/fieldData/preview";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

  // 清除执行记录
  clearRecord(params, res, req){
    let apiUrl = config.serverUrl_BI + "/biEtlSyncPlan/clear";
    $request.handleRequest({
      method: 'post',
      params: params,
      actionUrl: apiUrl,
    }, res);
  }

}

module.exports = dataArrangeModule;